/*
 * 全局filter
 * */

import { parseTime } from '@/utils/index';

export const parseTimeToCommon = (time, cFormat) => {
  return parseTime(time, cFormat);
};
// export const hasHref = ()=>{}
export const formatUTCTime = (time, format = 'yyyy-MM-dd HH:mm:ss') => {
  if (!time || time === 'null') {
    return '—— ——';
  }
  const t = new Date(time);
  const tf = function (i) {
    return (i < 10 ? '0' : '') + i;
  };
  // format = format || 'yyyy-MM-dd HH:mm:ss';
  return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) {
    switch (a) {
      case 'yyyy':
        return tf(t.getFullYear());
      case 'MM':
        return tf(t.getMonth() + 1);
      case 'mm':
        return tf(t.getMinutes());
      case 'dd':
        return tf(t.getDate());
      case 'HH':
        return tf(t.getHours());
      case 'ss':
        return tf(t.getSeconds());
    }
  });
};
